// pages/mine/mine.js
const gp = getApp().globalData;
const util = require("../../utils/util.js");
const net = require("../../utils/net.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    gymname:"",
    gymname_py:"",
    icon: gp.userInfo.avatarUrl
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.shopname();
  },
  shopname(){
    var that = this;
    var shopname = wx.getStorageSync("shop_name");
    if (shopname != null && shopname != undefined && shopname.length != 0) {
      that.setData({
        gymname: shopname
      })
      return;
    }
    net.request({
      url: "/GetShopInfo",
      data: {
        shop_id: gp.shop_id
      }, success(res) {
        if (res.data.flag) {
          gp.shop_name = shopname = res.data.data.shop_name;
          wx.setStorageSync("shop_name", res.data.data.shop_name);
          that.setData({
            gymname: shopname
          })
        } else {
          if (res.data.msg)
          wx.showToast({
            title: res.data.msg,
          })
        }
      }, fail(res) {

      }
    })
  },
  logout(){
    wx.removeStorageSync("shop_name");
    wx.removeStorageSync("shop_id");
    wx.removeStorageSync("id");
    gp.shop_name = null;
    gp.shop_id = null;
    gp.id = null;
    wx.reLaunch({
      url: '../index/index',
    })
  },
  navgo(){
    util.Forward("../resetpsw/resetpsw");
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})